package com.tegtech.starter.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import com.tegtech.starter.validator.annotation.Phone;

import cn.hutool.core.lang.Validator;

/**
 * Phone注解校验实现类
 * @Author Jun
 * @date 2020年5月2日 下午2:10:49
 */
public class PhoneValidator implements ConstraintValidator<Phone, String> {

	@Override
	public boolean isValid(String value, ConstraintValidatorContext context) {
		if(value == null || value.length() == 0) {
			return false;
		}
		return Validator.isMobile(value);
	}

}
